﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Wedo.Mvc.Utility;
using Wedo.Recognition.Domain.Models;
using Wedo.Recognition.Web.Controllers;
using Wedo.Recognition.Service;
using Wedo.Mvc.Pager;
using Wedo.Recognition.Domain;
using Wedo.Recognition.Repository;
namespace Wedo.IPRP.Web.Controllers
{
    public class BankController : EntityController<Bank, SearchModel>
    {
        private BankService service;
        public BankController(IUnitWork dbContext)
            : base(dbContext)
        {
            service = new BankService(_dbContext);
        }


        protected override Wedo.Service.Common.IBaseService<Bank> EntityService
        {
            get { return service; }
        }

        protected override  PagedList<Bank> GetSearchPagedList(SearchModel where)
        {
            where=where ?? new SearchModel();
            if (where.Keyword.IsNotNullOrWhiteSpace())
            {
                return service.GetAll(m => m.BankCode.Contains(where.Keyword) || m.BankName.Contains(where.Keyword)).OrderBy(m => m.BankCode).ToPagedList(1, 10);
            }
            else
                return service.All().OrderBy(m => m.BankCode).ToPagedList(1, 10);
        }
    }
}
